using System;
using FytSoa.Common.Utils;
using System.ComponentModel.DataAnnotations;
using FytSoa.Application.Crm;
using FytSoa.Application.Hr;
using FytSoa.Common.Enum;
using FytSoa.Domain.Crm;
using FytSoa.Domain.Erp;
using FytSoa.Domain.Hr;
using Masuit.Tools.Reflection;
using SqlSugar;

namespace FytSoa.Application.Erp;

/// <summary>
/// erp-销售表
/// </summary>
public class ErpSalesOrderDto : AppEntity
{
    /// <summary>
    /// 订单编号
    /// </summary>
    public string Number { get; set; }

    /// <summary>
    /// 客户ID
    /// </summary>
    [Required]
    public long CustomerId { get; set; } = 0;
    
    /// <summary>
    /// 客户信息
    /// </summary>
    public CrmCustomerSimpleDto Customer { get; set; }

    /// <summary>
    /// 负责人
    /// </summary>
    [Required]
    public long UserId { get; set; } = 0;
    
    /// <summary>
    /// 负责人
    /// </summary>
    public HrEmployeeSimpleDto Employee { get; set; }


    /// <summary>
    /// 下单时间
    /// </summary>
    public DateTime? OrderDate { get; set; } = DateTime.Now;

    /// <summary>
    /// 订单总额
    /// </summary>
    [Required]
    public decimal TotalAmount { get; set; } = 0;

    /// <summary>
    /// 已收金额
    /// </summary>
    public decimal PaidAmount { get; set; } = 0;

    /// <summary>
    /// 草稿','已审核','部分发货','已完成','已关闭
    /// </summary>
    public ErpSalesOrderStatusEnum OrderStatus { get; set; } = ErpSalesOrderStatusEnum.UnAudited;
    
    /// <summary>
    /// 草稿','已审核','部分发货','已完成','已关闭
    /// </summary>
    public string OrderStatusName=>OrderStatus.GetDescription();

    /// <summary>
    /// 是否开票
    /// </summary>
    public bool InvoiceStatus { get; set; } = true;

    /// <summary>
    /// 创建人
    /// </summary>
    public string CreateUser { get; set; }

    /// <summary>
    /// 创建时间
    /// </summary>
    [Required]
    public DateTime CreateTime { get; set; } = DateTime.Now;

    /// <summary>
    /// 更新人
    /// </summary>
    public string UpdateUser { get; set; }

    /// <summary>
    /// 更新时间
    /// </summary>
    public DateTime? UpdateTime { get; set; }

    /// <summary>
    /// 商品列表
    /// </summary>
    public List<ErpSalesOrderItemDto> List { get; set; } = new();
}

/// <summary>
/// erp-销售表
/// </summary>
public class ErpSalesOrderSimpleDto : AppEntity
{
    /// <summary>
    /// 订单编号
    /// </summary>
    public string Number { get; set; }
}